package com.ty.controller;

import com.ty.pojo.HeartMethod;
import com.ty.service.HeartMethodService;
import com.ty.vo.PageResult;
import com.ty.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.List;

@RestController
@CrossOrigin
@EnableSwagger2
@RequestMapping("/heartMethod")
public class HeartMethodController {
    @Autowired
    private HeartMethodService heartMethodService;
    //查询页面数据
    @GetMapping("/getHeartMethodList")
    public SysResult getHeartMethodList(@RequestBody HeartMethod heartMethod,PageResult pageResult){
        pageResult = heartMethodService.getHeartMethodList(pageResult,heartMethod);
        System.out.println(pageResult);
        return SysResult.success(pageResult);
    }

    //新增数据
    @PostMapping("/insertHeartMethod")
    @Transactional
    public SysResult insertHeartMethod(@RequestBody HeartMethod heartMethod){
        heartMethodService.insertHeartMethod(heartMethod);
        return SysResult.success();
    }
    //修改数据
    @PutMapping("/updateHeartMethod")
    @Transactional
    public SysResult updateHeartMethod(@RequestBody HeartMethod heartMethod){
        heartMethodService.updateHeartMethod(heartMethod);
        return SysResult.success();
    }
    @PutMapping("/updateState/{id}")
    @Transactional
    public SysResult updateState(@PathVariable Integer id){
        heartMethodService.updateState(id);
        return SysResult.success();
    }
}
